ENT-13880: Added error-checks for half-promises / attrs without promiser outside of macros#86
Merged
olehermanse merged 2 commits intocfengine:mainfrom Apr 29, 2026
Merged
Conversation
b5f6a1a to
9f32835
Compare
olehermanse
reviewed
Apr 23, 2026
olehermanse
reviewed
Apr 23, 2026
olehermanse
reviewed
Apr 24, 2026
2926000 to
a575aa3
Compare
Missing semicolons not handled, leave this to the formatter.
a575aa3 to
bfed5d1
Compare
olehermanse
reviewed
Apr 29, 2026
| self.old_state = deepcopy(self.__dict__) | ||
| self.macro = macro_type.split(" ")[-1] | ||
| elif macro_type.startswith("@else"): | ||
| self.macro = "else" |
Member
There was a problem hiding this comment.
In the future it might be valuable to know what macro we are in the @else of. (Essentially, !minimum_version(3.24) for example).
olehermanse
reviewed
Apr 29, 2026
Comment on lines
+779
to
+794
| prev_sib = node.prev_named_sibling | ||
| while prev_sib and prev_sib.type == "comment": | ||
| prev_sib = prev_sib.prev_named_sibling | ||
| prev_type = prev_sib.type if prev_sib else None | ||
| if not state.macro: | ||
| _highlight_range(node, lines) | ||
| print( | ||
| f"Error: Found promise attribute with no parent-promiser outside of a macro {location}" | ||
| ) | ||
| return 1 | ||
| elif prev_type != "macro": | ||
| _highlight_range(node, lines) | ||
| print( | ||
| f"Error: Multiple promise attributes with ending semicolon found inside macro '{state.macro}' {location}" | ||
| ) | ||
| return 1 |
Member
There was a problem hiding this comment.
No need for else when you do early return. No need to look through previous nodes when you are not going to use the result;
Suggested change
| prev_sib = node.prev_named_sibling | |
| while prev_sib and prev_sib.type == "comment": | |
| prev_sib = prev_sib.prev_named_sibling | |
| prev_type = prev_sib.type if prev_sib else None | |
| if not state.macro: | |
| _highlight_range(node, lines) | |
| print( | |
| f"Error: Found promise attribute with no parent-promiser outside of a macro {location}" | |
| ) | |
| return 1 | |
| elif prev_type != "macro": | |
| _highlight_range(node, lines) | |
| print( | |
| f"Error: Multiple promise attributes with ending semicolon found inside macro '{state.macro}' {location}" | |
| ) | |
| return 1 | |
| if not state.macro: | |
| _highlight_range(node, lines) | |
| print( | |
| f"Error: Found promise attribute with no parent-promiser outside of a macro {location}" | |
| ) | |
| return 1 | |
| prev_sib = node.prev_named_sibling | |
| while prev_sib and prev_sib.type == "comment": | |
| prev_sib = prev_sib.prev_named_sibling | |
| prev_type = prev_sib.type if prev_sib else None | |
| if prev_type != "macro": | |
| _highlight_range(node, lines) | |
| print( | |
| f"Error: Multiple promise attributes with ending semicolon found inside macro '{state.macro}' {location}" | |
| ) | |
| return 1 |
olehermanse
approved these changes
Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.